﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace assignment7
{
    public class orderitem
    {
        private string name;
        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
            }
        }

        private int number;
        public int Number
        {
            get
            {
                return number;
            }
            set
            {
                if (number >= 0) number = value;
                else Console.WriteLine("item的数量必须大于0");
            }
        }

        private double price;
        public double Price
        {
            get
            {
                return price;
            }
            set
            {
                if (price >= 0) price = value;
                else Console.WriteLine("item的价格必须大于0");
            }
        }

        public orderitem()
        {//无参构造函数
            this.Name = string.Empty;
            this.Number = 0;
            this.Price = 0;
        }

        public double getPrice()
        {
            return this.Number * this.Price;
        }

        public orderitem(string name, int number, double price)
        {
            this.Name = name;
            this.number = number;
            this.price = price;
        }

    }
}
